package com.breeze.modularproject;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.breeze.common.autoservice.login.ILoginService;
import com.breeze.base.BServiceLoader;
import com.breeze.common.login.IUser;
import com.breeze.register.RegisterActivity;

import brouter.annotation.BRouter;
import brouter.annotation.Parameter;
import brouter.api.ParameterManager;

@BRouter(path = "/app/MainActivity")
public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";
    @Parameter(name = "/login/LoginUser")
    IUser loginUser;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ParameterManager.bind(this);
        Log.i(TAG, "onCreate: login bean=" + loginUser.getUserInfo());
    }

    // 从App壳 到 Login模块
    public void startLoginModule(View view) {
        // 1. 普通方式
        // startActivity(new Intent(MainActivity.this, LoginActivity.class));
        // 2. BRouter方式
        /*RouterManager.getInstance().build(BRouterPathLogin.LoginActivity)
                .withString("name", "breeze")
                .withString("password", "123456")
                .navigation(this);*/
        // 3. AutoService 方式
        ILoginService next = BServiceLoader.load(ILoginService.class);
        next.startLoginActivity(this, "haha", "222");
    }

    public void startRegisterModule(View view) {
        startActivity(new Intent(MainActivity.this, RegisterActivity.class));
    }
}